package com.liuhuan.sendmessage.config;

import com.cloopen.rest.sdk.BodyType;
import com.cloopen.rest.sdk.CCPRestSmsSDK;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class SMSConfig {
    @Value("${sms.server.ip}")
    private String serverIp;

    @Value("${sms.server.port}")
    private String serverPort;

    @Value("${sms.account.sid}")
    private String accountSId;

    @Value("${sms.account.token}")
    private String accountToken;

    @Value("${sms.app.id}")
    private String appId;

    @Bean
    public CCPRestSmsSDK smsSdk() {
        CCPRestSmsSDK sdk = new CCPRestSmsSDK();
        sdk.init(serverIp, serverPort);
        sdk.setAccount(accountSId, accountToken);
        sdk.setAppId(appId);
        sdk.setBodyType(BodyType.Type_JSON);
        return sdk;
    }
}
